package com.bw.aop;

import com.alibaba.fastjson.JSON;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class MyAroundAop {



    @Around("execution(* com.bw.service.*.*(..))")
    private Object aop(ProceedingJoinPoint joinPoint) throws Throwable {

        String name = joinPoint.getSignature().getName();// 原对象方法的 名称
        System.out.println("方法的名称" + name);
        Object[] args = joinPoint.getArgs(); // 方法的入参
        System.out.println("方法的入参" + JSON.toJSONString(args));
        long l = System.currentTimeMillis();
        Object proceed = joinPoint.proceed(); // 执行原方法

        long l2 = System.currentTimeMillis();

        System.out.println("方法的执行耗时"   + (l2-l));

        System.out.println("方法的返回值" + JSON.toJSONString(proceed));
        return proceed;
    }
}
